<?php
/**
 * 微博音乐插件
 * 
 * Created		: 2011-07-06
 * Modified		: 2011-07-06 
 * @link		: http://qixbo.com
 * @copyright	: (C) 2011 Qixbo Inc.
 * @version		: 0.1.0
 * @author		: Joseph Chen (jsph.chen@gmail.com)
 */
class MbMusic
{
	
	protected static $tbl		= 'mb_video';
	protected static $priKey	= 'id';
	
	public static function execute($data)
	{
		if (!isset($data['video_url'])) {
			return false;
		}
		$info = parse_url($data['video_url']);
		switch ($info['host']) {
			case 'v.youku.com':
				preg_match("/id\_(\w+)[=.]/", $data['video_url'], $matches);
				break;
				
			case 'www.tudou.com' :
				preg_match("#view/([-\w]+)/#", $data['video_url'], $matches);
				break;
				
			case 'my.tv.sohu.com':
				preg_match("#vw/(\d+)#", $data['video_url'], $matches);
				break;
				
			case 'v.ku6.com':
				preg_match("#/([-\w]+)\.html#", $data['video_url'], $matches);
				break;
				
			case 'www.56.com':
				preg_match("#/v_(\w+)\.html#", $data['video_url'], $matches);
				break;
		}
		if (empty ($matches[1])) {
			return false;
		}
		
		return $data;
	}
	
}




